<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<html>
<jsp:include page="../layout/_nav.jsp"></jsp:include>
<head>
    <jsp:include page="../layout/_import.jsp"></jsp:include>
    <link rel="stylesheet" href="css/vetsearch_result.css">
    <title>客户查询界面</title>
</head>
<body>
<main>
    <div class="container">
        <h2>用户管理</h2>

        <form action="custom" method="post">
            <input type="hidden" name="m" value="search">
            <div class="row">
                <label  class="my-1 mr-2 " for="colFormLabelLg" style="margin-left: 17px;">用户姓名</label>
                <div class="col col-md-6">
                    <input type="text" class="form-control" name="customerName" id="colFormLabelLg">
                </div>
                <div class="col col-md-4">
                    <input type="submit" class="btn btn-primary" value="查询"/>
                    <a href="/custom" class="btn btn-primary">显示所有</a>
                </div>
            </div>
        </form>
        <table class="table" style="text-align: center">
            <thead class="thead-dark">
            <tr>
                <th scope="col">id</th>
                <th scope="col">身份</th>
                <th scope="col">姓名</th>
                <th scope="col">电话</th>
                <th scope="col">地址</th>
                <th scope="col">操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${users}" var="u">
                <tr>
                    <th scope="row">${u.id}</th>
                    <td>${u.role}</td>
                    <td>${u.name}</td>
                    <td>${u.tel}</td>
                    <td>${u.address}</td>
                    <td>
                        <form action="${pageContext.request.contextPath}/custom" method="post">
                            <input type="hidden" name="m" value="del">
                            <input type="hidden" name="id" value="${u.id}">
                            <a href="/admin/userEdit.jsp?m=edit&id=${u.id}" class="btn btn-primary">编辑</a>
                            <button type="submit" class="btn btn-danger"
                                    onclick="return confirm('确认删除？')">删除
                            </button>
                        </form>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
        <c:if test="${not empty msg}">
            <div class="alert alert-danger">${msg}</div>
        </c:if>

        <a href="/admin/userAdd.jsp" class="btn btn-primary">添加用户</a>
    </div>

</main>

</body>

</html>
